# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - disable assembly on v5/v6

pkgbase=dav1d
pkgname=(dav1d dav1d-doc)
pkgver=0.8.2
pkgrel=1
pkgdesc='AV1 cross-platform decoder focused on speed and correctness'
url='https://code.videolan.org/videolan/dav1d/'
arch=('x86_64')
license=('BSD')
makedepends=('meson' 'ninja' 'nasm' 'doxygen' 'graphviz' 'xxhash')
source=(https://downloads.videolan.org/pub/videolan/${pkgname}/${pkgver}/${pkgname}-${pkgver}.tar.xz{,.asc}
        https://code.videolan.org/videolan/dav1d-test-data/-/archive/${pkgver}/dav1d-test-data-${pkgver}.tar.gz)
sha512sums=('c2d69adcc1f26c8700592e08306828aeaa3bf035e90a09bce4f2a494678645f37d4d0c5fc201eb4c369099f8f27e1325ca3421264aa1c2ffdad94868cc0504af'
            'SKIP'
            '36400a954c312b03e66b14c2b133d17bd3fe1c63013c37f04b75c4f35c55d6d7244029fc4f11d81e832f154d3946cc50145023b7750e2b2a9586d6a6a577c572')
b2sums=('4c08122506bda64a1a9abd237d2aa5cf1d1e3a84bea34ae96589bb577eebf74432bcfb219da69f79c8656539193299feb19f4e54b9f537a06a10449e3117fa83'
        'SKIP'
        '3e53c9c0d2c62910ab252c6a30229833b40c2fd6c77d3d965dd015bb0467d8e6c129423e4228c5a5ae8b9bdeeab9a196786178209011a4bffa2d6890393509ff')
validpgpkeys=('65F7C6B4206BD057A7EB73787180713BE58D1ADC') # VideoLAN Release Signing Key

prepare() {
  cd ${pkgbase}-${pkgver}
  ln -s "${srcdir}/dav1d-test-data-${pkgver}" tests/dav1d-test-data
}

build() {
  cd ${pkgbase}-${pkgver}
  [[ $CARCH == "arm" || $CARCH == "armv6h" ]] && meson_options="-Dbuild_asm=false"
  arch-meson -Dtestdata_tests=true $meson_options build
  ninja -C build all doc/html
}

check() {
  cd ${pkgbase}-${pkgver}/build
  meson test
}

package_dav1d() {
  depends=('glibc')
  provides=('libdav1d.so')
  optdepends=('dav1d-doc: HTML documentation')

  cd ${pkgbase}-${pkgver}
  DESTDIR="${pkgdir}" ninja -C build install
  install -Dm 644 README.md CONTRIBUTING.md NEWS -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 COPYING -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

package_dav1d-doc() {
  pkgdesc+=" (documentation)"

  cd ${pkgbase}-${pkgver}
  install -d "${pkgdir}/usr/share/doc/${pkgbase}"
  cp -r build/doc/html -t "${pkgdir}/usr/share/doc/${pkgbase}"
  install -Dm 644 COPYING -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
